package 力扣._2048_下一个更大的数值平衡树;

class Solution {

    public int nextBeautifulNumber(int n) {
        for (int i = n+1; i <= 10000000; i++) {
            int[] cnt = new int[10];
            int t = i;
            while (t > 0) {
                cnt[t % 10]++;
                t /= 10;
            }
            int j=0;
            for ( ; j < cnt.length; j++) {
                if(cnt[j]!=j && cnt[j]!=0)
                    break;
            }
            if(j==cnt.length)
                return i;
        }
        return -1;
    }

    public static void main(String[] args) {
        Solution s = new Solution();
    }

}